package com.xlh.dao.courseTest.helper;

import com.xlh.dao.courseTest.ExperimentStatisticsPassMapper;
import com.xlh.dao.courseTest.ExperimentStatisticsStepPassMapper;
import com.xlh.pojo.courseTest.ExperimentStatisticsPass;
import com.xlh.pojo.courseTest.example.ExperimentStatisticsPassExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author cfz
 */
@Repository
public class ExperimentStatisticsPassMapperHelper {


    @Autowired
    private ExperimentStatisticsPassMapper experimentStatisticsPassMapper;

    public List<ExperimentStatisticsPass> findExperimentStatisticsPassByCondition(Long chapterId, Long courseId, Long classId, Long userId){

        ExperimentStatisticsPassExample isHavePassSearch = new ExperimentStatisticsPassExample();
        isHavePassSearch.createCriteria().andChapterIdEqualTo(chapterId.intValue())
                    .andCourseIdEqualTo(courseId.intValue())
                    .andClassIdEqualTo(classId.intValue())
                    .andUserIdEqualTo(userId.intValue());
        List<ExperimentStatisticsPass> passRecord = experimentStatisticsPassMapper.selectByExample(isHavePassSearch);

        return passRecord;
    }


    public List<ExperimentStatisticsPass> findExperimentStatisticsPassByCondition(List<Integer> chapterIds, Long courseId, Long classId, Long userId){

        ExperimentStatisticsPassExample example = new ExperimentStatisticsPassExample();
        example.createCriteria().andChapterIdIn(chapterIds).andCourseIdEqualTo(courseId.intValue()).andClassIdEqualTo(classId.intValue()).andUserIdEqualTo(userId.intValue());
        // 如果所有任务已通过标记当前章节通过
        List<ExperimentStatisticsPass> list = experimentStatisticsPassMapper.selectByExample(example);

        return list;
    }






}
